var scale = 1.5;
var pdf = 0;

function loadPDF(file_path)
{
    'use strict';

    PDFJS.getPdf(file_path, function renderPDFData(data) 
    {
        PDFJS.disableWorker = true;
        pdf = new PDFJS.PDFDoc(data);
        var page = pdf.getPage(6);
        var canvas = document.getElementById('viewer_canvas');
        var context = canvas.getContext('2d');
        canvas.height = page.height * scale;
        canvas.width = page.width * scale;
        page.startRendering(context);
    });
}

function renderPage(number)
{
    var page = pdf.getPage(number);
    var canvas = document.getElementById('viewer_canvas');
    var context = canvas.getContext('2d');
    canvas.height = page.height * 0.2;
    canvas.width = page.width * 0.2;
    alert(pdf.numPages);
    page.startRendering(context);
}

function renderThumbnails()
{
    var thumb = "";
    var page = 0;
    var canvas = "";
    var context = 0;
    for(var i=1; i<=pdf.numPages; i++)
    {
        thumb = "<tr>" +
                    "<td>" +
                        "<canvas id='thumb_"+ i +"'></canvas>" +
                    "</td>" +
                "</tr>"+
                "<tr>" +
                    "<td>" +
                        "<label>" + i + "</label>" +
                    "</td>" +
                "</tr>";
        $('#thumb_nav table').html($('#thumb_nav table').html() + thumb);
 
        page = pdf.getPage(i);
        canvas = document.getElementById('thumb_' + i);
        context = canvas.getContext('2d');
        canvas.height = page.height * 0.2;
        canvas.width = page.width * 0.2;
        page.startRendering(context);
    }
}